﻿ALTER VIEW [dbo].[View_Charge] AS 
SELECT a.*,b.KCCID, d.KeyCardName,ISNULL(U.UserName,'') AS Operator FROM dbo.CS_Charge a 
JOIN CS_Charge_KeyCard b ON a.ID=b.ChargeID AND a.ClinicID=b.ClinicID
JOIN CS_CustomerKeyCard c ON b.KCCID=c.KCCID AND b.ClinicID=c.ClinicID
JOIN Ref_KeyCard d ON c.KeyCardNo=d.KeyCardNo AND c.ClinicID=d.ClinicID
LEFT JOIN dbo.sys_User U ON a.OperatorID=U.UserId AND a.ClinicID=U.ClinicID
GO
